const Actions = require('./actions');
const DB = require('app/db.js');
import { Storage } from 'clientConfig/util/StoreData'
import { Toast } from 'saltui';
module.exports = Reflux.createStore({
    listenables: [Actions],
    data: {

    },
    onGetRepairList: function (pageNum, props, success, error) {
        let t = this;
        DB.Teacher.get_repair_list({
            schoolId: Storage.get('user.schoolId'),
            pageIndex: pageNum,
            teacherId: Storage.get('user.teacherId')
        })
            .then((content) => {
                if (content.code == 1) {
                    let schoolId = content.check.schoolId;
                    var list = [];
                    var obj = {};
                    if (content && content.data) {
                        content = content.data.list;
                        list = content;
                    }
                    const hasNoMore = list.length < props.pageSize;
                    t.data.listData = list;
                    if (success) {
                        success(hasNoMore, list);
                    } else if (!content || !success) {
                        error();
                    }
                }else{
                    Toast.show({
                        type: 'error',
                        content: '系统异常'
                    });
                }

            })
            .catch(function (error) {
                Toast.show({
                    type: 'error',
                    content: '系统异常'
                });
            });
    },
    updateComponent: function () {
        this.trigger(this.data);
    }
});
